package cn.net.yugu.doraemon.common.jackson.serializer;

import java.io.IOException;
import java.time.Instant;

import cn.net.yugu.doraemon.common.util.function.ToStringFunction;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * @author xiangzr
 */
public class InstantStringJsonSerializer extends JsonSerializer<Instant> {

    @Override
    public void serialize(Instant value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeString(ToStringFunction.InstantToStringFunction.applyAsString(value));
    }

}
